<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文档标题</title>
    <style>
        input {
            width: 200px;
        }

        .bg-white {
            background-color: white;
        }

        .bg-black {
            background-color: black;
            color: white;
        }
    </style>
</head>
<body>
<ul id="list">
    <input>
    <input>
    <input>
    <input>
</ul>

<script>

  window.onload = function () {
    const inputs = document.getElementsByTagName("input");

    // const callback = event => {
    //   for (const input of inputs) {
    //     input.className = "bg-white";
    //   }
    //   event.target.className = "bg-black";
    // };
    for (const input of inputs) {
      input.className = "bg-white";
      input.onfocus = event => {
        event.target.className = "bg-black";
      };
      input.onblur = event => {
        event.target.className = "bg-white";
      };
    }
  }
</script>
</body>
</html>
